import logRegres
from numpy import *
#梯度上升
dataArr,labelMat = logRegres.loadDataSet()
#print("dataArr\n",dataArr)
#print("labelMat\n",labelMat)
weights = logRegres.gradAscent(dataArr,labelMat)
print("logRegres.gradAscent(dataArr,labelMat):\n",weights)
print("weights.getA()\n",weights.getA())
#logRegres.plotBestFit(weights.getA())#矩阵转成一个ndarray numpy.matric.getA
#######################getA的小知识##############################
# >>>weights = mat(w)         #转换为numpy矩阵
# >>>weights
# matrix([[ 1.],
        # [ 1.],
        # [ 1.]])
# >>>s = weights.getA()           #将numpy矩阵转换为数组
# >>>s
# array([[ 1.],
       # [ 1.],
       # [ 1.]])
#########################################################
#随机梯度上升
#weights = logRegres.stocGradAscent0(array(dataArr),labelMat)
#logRegres.plotBestFit(weights)
#改进的梯度上升
weights = logRegres.stocGradAscent1(array(dataArr),labelMat)
logRegres.plotBestFit(weights)
#预测马生病的例子
logRegres.multiTest()